package com.flash.BusinessData.service.impl;

import com.flash.BusinessData.entity.securityAccrued;
import com.flash.BusinessData.mapper.SecurityAccruedMapper;
import com.flash.BusinessData.service.SecurityAccruedService;
import com.flash.BusinessParameters.service.SecurityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SecurityAccrueImpl implements SecurityAccruedService {
    @Autowired
    SecurityAccruedMapper securityAccruedMapper;

    @Override
    public List<securityAccrued> securityAccruedSelect(int page, int limit,securityAccrued securityAccrued) {
        Map map = new HashMap();
        map.put("page",(page-1)*limit+1);
        map.put("limit",limit*page);
        map.put("strWhere",buildStrWhere(securityAccrued));
        return securityAccruedMapper.securityAccruedSelect(map);
    }


    /**
     * 生成SQL条件
     * @param securityAccrued 实体类
     * @return  条件的字符串  where 1=1 “   and userName  like '%admin%' and roleId =1 ”
     */
    public String buildStrWhere(securityAccrued securityAccrued){
        StringBuffer strWhere=new StringBuffer("");
        if(securityAccrued.getBusinessTime()!=null && !securityAccrued.getBusinessTime().equals(""))
        {
            strWhere.append(" and businessTime like '%" + securityAccrued.getBusinessTime() + "%'");
        }
        return strWhere.toString();
    }


    @Override
    public int CountSecurityAccrued() {
        return securityAccruedMapper.CountSecurityAccrued();
    }

    @Override
    public int SecurityAccruedInsert(securityAccrued securityAccrued) {
        return securityAccruedMapper.SecurityAccruedInsert(securityAccrued);
    }

    @Override
    public int SecurityAccruedDelete(String securityAccruedId) {
        return securityAccruedMapper.SecurityAccruedDelete(securityAccruedId);
    }

    @Override
    public int SecurityAccruedUpdate(securityAccrued securityAccrued) {
        return securityAccruedMapper.SecurityAccruedUpdate(securityAccrued);
    }

    @Override
    public int deleteSecurityAccruedByPojo(securityAccrued securityAccrued) {
        return securityAccruedMapper.deleteSecurityAccruedByPojo(securityAccrued);
    }

    @Override
    public int SecurityAccruedDeletes(securityAccrued securityAccrued) {
        return securityAccruedMapper.SecurityAccruedDeletes(securityAccrued);
    }

    @Override
    public String SecurityAccruedId(securityAccrued securityAccrued) {
        return securityAccruedMapper.SecurityAccruedId(securityAccrued);
    }

}
